<?php
class Lead_Markup_Xhtml_Form
{
    
    public static function label($value, $id = null, $class = null, $for = null)
    {
        $output = '<label';

        if($id)
            $output .=" id=\"{$id}\"";
            
        if($class) {
            if(is_array($class))
                $class = implode(' ', $class);
            $output .=" class=\"{$class}\"";
        }
        
        if($for)
            $output .=" for=\"{$for}\"";
        
        $output .= '>' . $value . "</label>\n";
        
        return $output;
    }
    
    
    
    public function passwordInput($id, $name, $class = null, $value = null, $labelText = null)
    {
        $output = ($labelText) ? self::label($labelText) : '';
        
        $output .= "<input type=\"password\" id=\"{$id}\" name=\"{$name}\"";

        if($class) {
            if(is_array($class))
                $class = implode(' ', $class);
            $output .=" class=\"{$class}\"";
        }

        if($value)
            $output .=" value=\"{$value}\"";
            
        $output .= " />\n";
        
        return $output;
        
    }
    
    public function textInput($id, $name, $class = null, $value = null, $labelText = null)
    {
        $output = ($labelText) ? self::label($labelText) : '';
        
        $output .= "<input type=\"text\" id=\"{$id}\" name=\"{$name}\"";

        if($class) {
            if(is_array($class))
                $class = implode(' ', $class);
            $output .=" class=\"{$class}\"";
        }

        if($value)
            $output .=" value=\"{$value}\"";
            
        $output .= " />\n";
        
        return $output;
        
    }
    
    
    public function textArea($id, $name, $class = null, $value = null, $labelText = null)
    {
        $output = ($labelText) ? self::label($labelText) : '';
        
        $output .= "<textarea id=\"{$id}\" name=\"{$name}\"";

        if($class) {
            if(is_array($class))
                $class = implode(' ', $class);
            $output .= " class=\"{$class}\"";
        }
            
        $output .= '>';
        
        if($value)
            $output .= $value;
            
        $output .= "</textarea>\n";

        
        return $output;

    }
    
    
    public function button($id, $name, $class, $value, $type = 'button')
    {
        $output = "<button id=\"{$id}\" name=\"{$name}\" type=\"{$type}\"";
        
        if($class) {
            if(is_array($class))
                $class = implode(' ', $class);
            $output .= " class=\"{$class}\"";
        }
        
        $output .= ">{$value}</button>\n";

        return $output;
    }
    
    
}